#ifndef __LINKAGE_ACTION_TABLE_H__
#define __LINKAGE_ACTION_TABLE_H__

#include <stdint.h>


//
typedef struct _LINKAGE_ACTION{
    int64_t  id;          //联动条件ID
    int64_t  linkageID;   //联动规则ID
    int64_t  deviceID;    //设备ID
    int64_t  commandID;   //指令ID
    int      sort;        //序号
    int      delayTime;   //延时时间单位s，默认0表示不延时,
    char     value[32];   //值
    struct _LINKAGE_ACTION* prev;
    struct _LINKAGE_ACTION* next;
}T_LINKAGE_ACTION;

/**
 * @brief 测点模型
 */
typedef struct _LINKAGE_ACTION_LIST{
    int  count;
    T_LINKAGE_ACTION* tail;
    T_LINKAGE_ACTION* head;
}T_LINKAGE_ACTION_LIST;


extern void dbLinkageActionInit();
extern int  createLinkageActionTable();
extern int  insertLinkageAction(T_LINKAGE_ACTION* action);
extern int  replaceLinkageAction(T_LINKAGE_ACTION* action);
extern int  deleteLinkageAction(T_LINKAGE_ACTION* action);
extern int  selectLinkageAction(const char* sql, T_LINKAGE_ACTION_LIST* actionList);



#endif // __LINKAGE_ACTION_TABLE_H__